﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace PhilWicklund.com.FacebookParts
{
    public class InvitationPart: System.Web.UI.WebControls.WebParts.WebPart
    {
        private string actionText = "";
        
        protected override void CreateChildControls()
        {
            
            try
            {
                StringBuilder script = new StringBuilder();
                script.Append("<fb:serverfbml style=\"width: 100%;\">")
                    .Append("<script type=\"text/fbml\">")
                    .Append("  <fb:fbml>")
                    .Append("      <fb:request-form")
                    .Append("                action=\"<url for post invite action, see wiki page for fb:request-form for details>\"")
                    .Append("                method=\"POST\"")
                    .Append("                invite=\"true\"")
                    .Append("                type=\"XFBML\"")
                    .Append("                content=\"\"")
                    .Append("          >")
                    .Append("                <fb:multi-friend-selector")
                    .Append("                showborder=\"false\"")
                    .Append("                actiontext=\"Invite your friends to use Connect.\">")
                    .Append("    </fb:request-form>")
                    .Append("  </fb:fbml>")

                    .Append("</script>")
                    .Append("</fb:serverfbml>");

                this.Controls.Add(new LiteralControl(script.ToString()));
            }
            catch (Exception e) { this.Controls.Add(new LiteralControl(e.Message)); }
        }
    }
}
